import React from "react";
const Index = () => {
    const navigate = React.$Router.useNavigate()
    const [list,setList] = React.useState([])
    const [finished,setFinished] = React.useState(false)
    const [loading,setLoading] = React.useState(false)
    const [LoginUser, setLoginUser] = React.useState(React.$Cookie.load('LoginUser') ? React.$Cookie.load('LoginUser') : {})
    const load = () => {
        setFinished(true)
        setLoading(true)
        // getCollectCate()
    }
  const onBack = () => {
    navigate(-1);
  };
  React.useEffect(() => {
    // let LoginUser = React.$Cookie.load('LoginUser') ? React.$Cookie.load('LoginUser') : {}

    // setLoginUser(LoginUser)
    getCollectCate()
},[])
  const getCollectCate=async()=>{
        let data = {
            busid:LoginUser.id
        }

        let result = await React.$Api.CateCollect(data)
        // console.log(result)
        if(result.code === 1)
        {

            setList(result.data)


        }else{
            setFinished(true)
            React.$Vant.Toast.info(result.msg)
            return false
        }

    
  }
  const Items = () => {
    return list.map((item,index) => {
        return (
            <li key={index}>
                <React.$Router.NavLink to={"/category/category/info?id=" + item.id}>
                    <img src={item.image_text} alt="" />
                    <p>{item.name}</p>
                    <span>{item.createtime_text}</span>
                </React.$Router.NavLink>
            </li>
        )
    })
}
  return (
    <>
      {/* 导航栏 */}
      <React.$Vant.Sticky>
        <React.$Vant.NavBar
          title="收藏文章列表"
          onClickLeft={onBack}
          zIndex="10"
        />
      </React.$Vant.Sticky>
      <React.$Vant.List className="catelist" finished={finished} onLoad={load} offset={5} loading={loading} autoCheck={false}>
                    <div className='lest_xs'>
                        <ul>
                            <Items />
                        </ul>
                    </div>
                </React.$Vant.List>
    </>
  );
};
export default Index;
